<?
//Message 0.1.2
class message{
    private $message;
    private $type;
    private $is_error;
    private $addation;
	private $is_print;
    
    function __construct($message, $type="ok", $is_print=false, $is_error=0, $addation=array()){
        $this->message=$message;
        $this->type=$type;
        $this->is_error=$is_error;
        $this->addation=$addation;
		$this->is_print=$is_print;
        if($is_error){
            global $mysql;
            $what=$addation;
            $what['message']=$message;
            $what['type']=$mysql->select_each("errors_types", "id", array('name'=>$type), "", "", "1");
            $mysql->insert("errors_log", $what);
        }
		if($is_print)
        	$this->mprint($message, $type);
    }
    
	private function mprint($message, $type){
        print("<div class=\"message_".$type."\">".$message."</div>");
    }
	
	private function mreturn($message, $type){
        return "<div class=\"message_".$type."\">".$message."</div>";
    }
	
	public function get()
	{
		return $this->mreturn($this->message, $this->type);
	}
}
?>